package com.zhixiang.xaec.entity.demo;


import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;



@Entity
@Table(name = "sys_demo_reader")
public class Reader
{
    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "MENO")
    private String meno;

    @Column(name = "NAME")
    private String name;
    //这块必须配CascadeType.REMOVE（影响级联保存）,CascadeType.MERGE（影响级联删除和级联更新）
    @OneToMany(mappedBy = "reader",cascade={CascadeType.REMOVE,CascadeType.MERGE},fetch=FetchType.LAZY)
    private Set<Book> books = new HashSet<Book>();

    public Reader()
    {}

    public Set<Book> getBooks()
    {
        return books;
    }

    public void setBooks(Set<Book> books)
    {
        this.books = books;
    }

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getMeno()
    {
        return meno;
    }

    public void setMeno(String meno)
    {
        this.meno = meno;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }
}